import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.util.ArrayList;

public class Demo {
    public static void main(String[] args) throws Exception{
        int index = 0;
        BufferedReader br = new BufferedReader(new FileReader("hodoop//data//students.txt"));
        BufferedWriter bw = new BufferedWriter(new FileWriter("hodoop//out//Demo//renshu.txt"+index));
        //名字里包含”白“的人数

        int count = 0;
        ArrayList<String> list = new ArrayList<>();
        String line = null;
        int rowNumber = 0;
        while ((line= br.readLine())!=null){
            rowNumber++;
            list.add(line);
            if (rowNumber == 140) {
                for (int i = 128*index; i < 128*index+128; i++) {
                    String info = list.get(i);
                    if (info.contains("白")) {
                        count++;
                    }
                    bw.write(info);
                    bw.newLine();
                    bw.flush();
                }
                rowNumber=12;
                index++;
                bw = new BufferedWriter(new FileWriter("hodoop//out//Demo//renshu.txt"+index));
            }
        }
        for (int i = list.size()-rowNumber; i < list.size(); i++) {
            String info = list.get(i);
            if (info.contains("白")) {
                count++;
            }
            bw.write(info);
            bw.newLine();
            bw.flush();
        }
        System.out.println("总共有"+count+"个名字里有白的人");
        br.close();
        bw.close();

    }
}
